package com.lxy.demo.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class DruidMannger {

    private static DataSource dataSource;

    static {
        Properties pro = new Properties();
        //获取路径  配置文件放src根目录下
        String path = DruidMannger.class.getClassLoader().getResource("druid.properties").getPath();
        try {
            pro.load(new FileInputStream(path));
            dataSource = DruidDataSourceFactory.createDataSource(pro);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static DataSource getDataSource(){
        return dataSource;
    }

}
